package com.java.grammer.equal.exer2;

/**
 * @author luzhikun
 * @date 2020/12/7- 16:23
 */
public class MyDate {
    public static void main(String[] args) {
        Equal equal = new Equal(2019, 12, 12);
        Equal equal1 = new Equal(2019, 12, 12);
        System.out.println(equal.equalss(equal1));

    }
}

class Equal {
    private int year;
    private int mouth;
    private int day;

    public Equal() {

    }

    public Equal(int year, int mouth, int day) {
        this.day = day;
        this.mouth = mouth;
        this.year = year;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    public int getMouth() {
        return mouth;
    }

    public void setMouth(int mouth) {
        this.mouth = mouth;
    }

    public int getDay() {
        return day;
    }

    public void setDay(int day) {
        this.day = day;
    }

    // @Override
    // public boolean equals(Object o) {
    //   if (this == o) return true;
    //  if (o == null || getClass() != o.getClass()) return false;
    //  Equal equal = (Equal) o;
    // return year == equal.year &&
    //          mouth == equal.mouth &&
    //         day == equal.day;
    // }
/*
    @Override
    public int hashCode() {
        return Objects.hash(year, mouth, day);
    }

 */
    public boolean equalss(Object ob) {
        if (this == ob) {
            return true;
        }
        if (ob instanceof Equal) {
            Equal equal = (Equal) ob;
            if (this.year == equal.year && this.mouth == equal.mouth && this.day == equal.day) ;
            return true;
        }
        return false;
    }
}
